package com.jixiang.order.config;


import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.jixiang.common.constants.CodeMqConstants.*;

@Configuration
public class OrderMqConfig {
    /**
     * 声明交换机
     * @return Direct类型交换机
     */
    @Bean
    public DirectExchange orderExchange(){
        return ExchangeBuilder.directExchange(MQ_EXCHANGE_ORDER).build();
    }

    /**
     * 第1个队列
     */
    @Bean
    public Queue orderQueue(){
        return new Queue(MQ_QUEUE_ORDER);
    }

    /**
     * 绑定队列和交换机
     */
    @Bean
    public Binding bindingQueue1WithOrder(Queue orderQueue, DirectExchange orderExchange){
        return BindingBuilder.bind(orderQueue).to(orderExchange).with(MQ_ROUTINGKEY_ORDER);
    }

}
